package com.zx.flow.db.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zx.flow.api.dict.FlowDict.NodeStatus;
import com.zx.flow.api.execute.model.FlowOperator;
import com.zx.flow.db.typehandler.FlowNodeStatusTypeHandler;
import com.zx.flow.db.typehandler.OperatorTypeHandler;
import com.zx.flow.db.typehandler.OperatorsTypeHandler;
import java.util.Date;
import java.util.List;
import lombok.Data;
import org.apache.ibatis.type.JdbcType;

@Data
@TableName(value = "flow_node", autoResultMap = true)
public class FlowNodeEntity {

    /**
     * id
     */
    private String id;

    /**
     * 流程id
     */
    private String flowId;

    /**
     * 开始时间
     */
    private Date startDateTime;

    /**
     * 结束时间
     */
    private Date endDateTime;

    /**
     * 触发的事件
     */
    private String eventCode;
    private String eventName;

    /**
     * 从哪个节点过来的
     */
    private String nodeFormId;
    private String nodeFormCode;
    private String nodeFormName;

    /**
     * 当前节点
     */
    private String nodeCurrentCode;
    private String nodeCurrentName;

    /**
     * 去哪个节点，未审批的时候为空
     */
    private String nodeToId;
    private String nodeToCode;
    private String nodeToName;

    /**
     * 所有可以审批人员的列表
     */
    @TableField(typeHandler = OperatorsTypeHandler.class, property = "operators", jdbcType = JdbcType.VARCHAR)
    private List<FlowOperator> operators;

    /**
     * 操作审批的人员
     */
    @TableField(typeHandler = OperatorTypeHandler.class)
    private FlowOperator operator;

    /**
     * 审批意见
     */
    private String remark;


    /**
     * 节点顺序，用于排序
     */
    private Integer nodeIdx;

    /**
     * 子流程ID[流程的每个node都可能触发子流程]
     */
    private String subFlowId;

    /**
     * 状态
     */
    @TableField(typeHandler = FlowNodeStatusTypeHandler.class)
    private NodeStatus status;

    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;
}
